package com.example.mapper;

import com.example.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     * 查询全部用户信息
     */

    @Select("select * from user")
    public List<User> list();

    /**
     * 根据id删除用户
     *
     * @param id
     */
    @Delete("delete from user where id=#{id}")
    public void deleteById(Integer id);

    /**
     * 新增用户
     *
     * @param user
     */
    //#{}就写User传进来的属性名就好
    @Insert("insert into user (username,password,tel,status) values (#{username},#{password},#{tel},#{status})")
    void add(User user);

    /**
     * 验证用户登录
     * @param user
     * @return
     */
    @Select("select * from user where password=#{username} and password=#{password}")
    User getByUsernameAndPassword(User user);

}
